/*
    This file is part of Manhunt.

    Manhunt is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Manhunt is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Manhunt.  If not, see <https://www.gnu.org/licenses/>.
 */

package snw.manhunt.commands;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import snw.manhunt.managers.GameManager;

public class RunnerCommand implements CommandExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "" + "只有玩家可以执行此命令！");
        } else if (GameManager.isGameStarted()) {
            sender.sendMessage(ChatColor.RED + "" + "命令失败，因为游戏已开始。");
        } else {
            if (GameManager.getRunner() == sender) {
                sender.sendMessage(ChatColor.GREEN + "" + "你已经是速通者了！");
            } else {
                GameManager.setRunner((Player) sender);
                sender.sendMessage(ChatColor.GREEN + "" + "你现在是速通者！");
            }
        }

        return true;
    }
}
